package com.datastructure.test.addlinklist.self;

import java.util.List;

public class ReverseLinkedList {
    public static ListNode reverseListNode(ListNode head){
        ListNode res = null;
        ListNode cur = head;
        while (cur!=null){
            ListNode temp = cur.next;
            cur.next=res;
            res = cur;
            cur=temp;
        }
        return res;
    }
}

class ListNode{
    int val;
    ListNode next;

    public ListNode(int val) {
        this.val = val;
    }
}
